#!/bin/bash

# 从用户输入读取 SCKEY 或从脚本参数获取
if [ -z "$1" ]; then
  read -p "Enter your ServerChan SCKEY: " SCKEY
else
  SCKEY=$1
fi

# 复制 ft.sh 脚本到 /usr/local/bin/
cp ft.sh /usr/local/bin/

# 替换 SCKEY 占位符
sed -i "s/YOUR_SCKEY_HERE/$SCKEY/" /usr/local/bin/ft.sh

# 给 ft.sh 设置可执行权限
chmod +x /usr/local/bin/ft.sh

# 将 ft.sh 添加到 SSH 的 PAM 配置中
echo "session optional pam_exec.so /usr/local/bin/ft.sh" >> /etc/pam.d/sshd

# 输出完成信息
echo "Installation completed successfully."